import numpy as np
from PIL import Image


def image_resize(image_list, font_size):
    length = len(image_list)
    result = np.zeros([length, font_size * font_size])
    for i in range(len(image_list)):
        image = image_list[i]
        padding_size = abs(image.shape[0] - image.shape[1]) // 2
        if image.shape[0] > image.shape[1]:
            pad = [(0, 0), (padding_size, padding_size)]
        else:
            pad = [(padding_size, padding_size), (0, 0)]
        new_image = np.lib.pad(image, pad, mode='constant', constant_values=1)
        image = np.array(
            Image.fromarray(new_image).resize([font_size, font_size]))
        result[i,] = image.flatten()
    return result
